<script type="text/javascript" src="/js/jquery.loading.js"></script>
<script type="text/javascript">
$(function(){

		$(".nav li:eq(2)").addClass("nav-li-hover");
		$(".type").change(function(){
			if($(".type:eq(0)").val() != "" && $(".type:eq(1)").val() != "" && $(".type:eq(2)").val() != ""){
				$.ajax({
					url:"/default/index/caculate",
					dataType:"json",
					type:"post",
					data:{"skus":$(".type:eq(0)").val(),"pallets":$(".type:eq(1)").val(),"items":$(".type:eq(2)").val()},
					success:function(json){
						$("#fee").html("<font color=#0675CC><b>$ "+json+"</font></b><br /> per month");
						$(".customPlan").show();
					}
				});
			}else{
				$("#fee").html("$ --,---");
				$(".customPlan").hide();
			}
		});
		
		$(".continue:eq(0)").click(function(){
			$.ajax({
				url:"/default/index/continue",
				dataTeyp:"json",
				type:"post",
				data:{"skus":"5","pallets":"0.25","items":"8"},
				success:function(){
					location.href="/default/index/register";
				}
			});
		});
		
		$(".continue:eq(1)").click(function(){
			$.ajax({
				url:"/default/index/continue",
				dataTeyp:"json",
				type:"post",
				data:{"skus":"5","pallets":"4","items":"24"},
				success:function(){
					location.href="/default/index/register";
				}
			});
		});
		
		$(".continue:eq(2)").click(function(){
			$.ajax({
				url:"/default/index/continue",
				dataTeyp:"json",
				type:"post",
				data:{"skus":"50","pallets":"18","items":"2000"},
				success:function(){
					location.href="/default/index/register";
				}
			});
		});
		
		$(".continue:eq(3)").click(function(){
			if($(".type:eq(0)").val() != "" && $(".type:eq(1)").val() != "" && $(".type:eq(2)").val() != ""){
				$.ajax({
					url:"/default/index/continue",
					dataTeyp:"json",
					type:"post",
					data:{"skus":$(".type:eq(2)").val(),"pallets":$(".type:eq(1)").val(),"items":$(".type:eq(0)").val()},
					success:function(){
						location.href="/default/index/register";
					}
				});
			}			
		});
		
	$("#tipDialog").dialog({
		autoOpen:false,
		modal:true,
		width:300,
		show:"slide",
		buttons:{
			"Close":function(){
				$(this).dialog("close");
			}
		}
	});
		
});

function submitRegForm(type){
	var customerEmail = '';
	var password = ''; 
	var rePassword = ''; 
	if(type==1){
		customerEmail = $('[name=customerEmail]').val();
		password = $('[name=password]').val();
		rePassword = $('[name=rePassword]').val();
	}else if(type==2){	// 横向注册框提交
		customerEmail = $('[name=customerEmail2]').val();
		password = $('[name=password2]').val();
		rePassword = $('[name=rePassword2]').val();
	}

	$.ajax({
		type:'POST',
		async:false,
		url:'/merchant/index/register',
		dataType:'json',
		data:{'customerEmail':customerEmail,'password':password,
			'rePassword':rePassword
		},
		success:function(json){
			if(json.ask){
				location.href="/merchant/my-account/index";
			}else {
				var html = "";
				$.each(json.error,function(k,v){
					html += v+"<br/>";
				});
				if(type==1){
					$("[name=customerEmail]").val(json.row.customer_email);
					$("[name=password]").val(json.row.customer_password);
					$("[name=rePassword]").val(json.row.rePassword);					
					$(".error").html(html);
				}else if(type==2){	// 横向注册框提交
					$("[name=customerEmail2]").val(json.row.customer_email);
					$("[name=password2]").val(json.row.customer_password);
					$("[name=rePassword2]").val(json.row.rePassword);
					$("#tipDialog").html(html);
					$("#tipDialog").dialog("open");
				}
			}
		}
	});
	return false;
}

function subCheck(){
	var delivery_country = $("[name=delivery_country]").val();
	var package_weight = $("[name=package_weight]").val();
	if( "" == delivery_country || "" == package_weight || isNaN(package_weight)){
		$("#tipDialog").html('Country Or Weight can\'t be empty !\r\n Or Weight not a Number !');
		$("#tipDialog").dialog("open");
		return false;
	}
	if($('#inquiry_result').css('display') == 'block') $('#inquiry_result').slideUp("slow");
	loading();
	$.ajax({
		type:'post',
		async:false,
		dataType:'json',
		url:'/default/index/ship-calc',
		data:{'delivery_country':delivery_country,'package_weight':package_weight},
		success:function(json){
			
			var html='';
			if(json.fee!=''){
				html='<h2 style="margin-right:auto">Inquiry Results</h2><table class="inquiry" border="1"><tr bgcolor="#f3f3f3"><th>Description</th><th>Delivery Country</th><th>Weight(Kg)</th><th>Costs</th></tr>';
				$.each(json.fee,function(k,v){
					html+='<tr><td>'+v.st_name+'</td><td>'+json.deliveryCountry.en_name+'</td><td>'+json.packageWeight+'</td><td style="color:#057ED0; font-weight:bold; font-size:15px;">'+v.currency.currency_symbol_left+v.inter_fee+'</td></tr>';	
				})
				html+='<tr style="border:none;"><td colspan="4"><input type="image" src="/images/calc-up.gif" onclick="$(\'#inquiry_result\').slideUp(\'show\')"></td></tr></table>';
				
			}else{
				html ='<span style="color:red; font-size:15px; font-weight:bold;">No Services !</span>'; 
			}
		    $('#inquiry_result').html(html).slideDown("slow");
			closeLoading();
		}
	});
}

</script>

<style type="text/css">
	.mybtn{
		border:1px solid #FFAE56;
		cursor: pointer;
		background: url('/images/blue-gradient.png') repeat-x ;
		height:30px;
		margin:10px 0;
		border-radius: 5px;
    }
	.mybtn:hover{
        background:#fd8419;
    }
	.myspan{
		color:#fff;
		font-size:15px;  
		font-weight:bold ;
    }
	.inquiry tr td,.inquiry tr th{
		padding:10px; text-align:center;
		border:1px solid #C6C6C6;
	}
</style>
<div class="content" id="content3">
        <div><h2 style="float:left;padding-top:20px;width:700px">Pricing &amp; Features</h2> <span style="float:right;margin-top:20px;margin-right:10px"><a href="/index/register">
			<img title="start free trial" alt="start free trial" src="/images/sign-up-now.png">
			</a></span>
        </div>
        <div class="pricing">

      </div>

<!-- 价格查询系统 -->
<div class="text-info">
    <div class="text-info-top"></div>
    <div class="text-info-body">
    	<h2 style="margin-right:auto">Price Inquiry System</h2>
        <form action="" >
            Delivery Country :
            <select name="delivery_country" class="input-width-1 cab_country_id required" style="width:160px;">
                <option value="">please select</option>
                <{foreach from=$countrys item=country}>
                    <option value="<{$country.country_id}>"><{$country.en_name}></option>
                    <!--<option value="<{$country.country_id}>"><{$country.en_name|cat:"&nbsp;"|cat:$country.cn_name}></option>-->
                <{/foreach}>			
            </select>
            Package Weight(Kg) : <input type="text" name="package_weight" /> (Eg:10g please fill in 0.01)
            <button type="button" class="mybtn" onclick="subCheck()">
                <span  class='myspan'>Postage Calculation</span>
            </button>
        </form>
        <div id="inquiry_result" style="display:none;"></div>
    </div>
   <div class="text-info-bottom"></div>
</div>



    <div class="clearFloat"></div>   
    </div>
<div id="tipDialog" style="display:none" title="Tip"></div>